package com.test;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/****
 * 
 *servlet的初始化过程
 *第一次请求会执行
     构造方法
   init 
    service 
     再次请求只会执行service 
     如果关闭服务会执行destroy
 */
@WebServlet("/demo3")
public class ServletDemo3  extends HttpServlet {
 
	private static final long serialVersionUID = 1L;

	public ServletDemo3() {
		 System.out.println("ServletDemo3  构造方法");
	}
	
	 @Override
		public void init() throws ServletException {
			 System.out.println("init方法执行");
		}
	
	 @Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		 System.out.println("service方法执行");
	}
	 
	 @Override
	public void destroy() {
		 System.out.println("destroy方法执行");
	}
	
}
